import execjs

ctx = execjs.compile("""
    function add(x, y) {
    return x + y;
}
""")

print(ctx.call("add",1,2))

import execjs

ctx = execjs.compile("""
function add(bi1,Pl$2){return bi1+Pl$2}
""")
print(ctx.call("add",1, 2))

import os
with open(os.getcwd()+'/js/demo1.js',encoding='utf-8') as f:
    js = f.read()

#通过compile命令转成一个js对象
docjs = execjs.compile(js)

#调用function
res= docjs.call('add',1,2)
print(res)

#调用变量
res = docjs.eval('guid')
print(res)
